<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css">
    <script src="https://cdn.jsdelivr.net/npm/jquery@3.2/dist/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery-scrollTo/2.1.3/jquery.scrollTo.min.js"></script>
    <link rel="stylesheet" type="text/css" href="/boke/css/me.css"/>
</head>
<body>
<!--导航-->
<nav class="ui inverted attached segment m-padded-tb-mini">
    <div class="ui container">
        <div class="ui inverted secondary stackable menu">
            <h2 class="ui teal header item">Bk</h2>
            <a href="/boke/view/index" class="active m-item item m-mobile-hide"><i class="mini home icon"></i>首页</a>
            <a href="/boke/view/types" class="m-item item m-mobile-hide"><i class="mini idea icon"></i>分类</a>
            <a href="/boke/view/tags" class="m-item item m-mobile-hide"><i class="mini tags icon"></i>标签</a>
            <a href="/boke/view/about" class="m-item item m-mobile-hide"><i class="mini info icon"></i>关于我</a>
            <div class="right item m-mobile-hide">
                <div class="ui icon input">
<!--                    <input type="text" placeholder="Search....">-->
<!--                    <i class="search link icon"></i>-->
                </div>
            </div>
        </div>
    </div>
    <a href="#" class="ui menu toggle black icon button m-right-top m-mobile-show">
        <i class="sidebar icon"></i><span th:text="${session.get('nikcname')}"></span>
    </a>
</nav>

<style>
    #yang{
        width: 1080px;
    }
</style>
<!--中间内容-->
<div class="m-container m-padded-tb-big">
    <div class="ui container">
        <div class="ui attached segment">
            <div class="ui horizontal link list">
                <div class="item">
                    <img src="/boke/images/grtx.jpg" alt="" class="ui avatar image">
                    <div class="content">
                        <a href="#" class="header" th:text="${user.getNickname()}">李小</a>
                    </div>
                </div>
                <div class="item">
                    <i class="calendar icon"></i><span th:text="${blog.getCreateDate()}"></span>
                </div>
                <div class="item">
                    <i class="eye icon"></i><span th:text="${blog.getViews()}"></span>
                </div>

            </div>
        </div>
        <div class="ui attached segment">
            <img th:src="${blog.getFirstPicture()}" alt="" class="ui centered rounded image" style="width: 400px;height: 300px">
        </div>
        <div class="ui attached padded segment">
            <div class="ui right aligned basic segment">
                <div class="ui orange basic label" th:text="${blog.getFlag()}">原创</div>
            </div>

            <h2 class="ui center aligned header" th:text="${blog.getTitle()}">刻意练习的清单</h2>

<!--            这个是渲染博客文章内容的-->
            <div id="content" class="typo typo-selection js-toc-content m-padded-lr-responsive m-padded-tb-large" th:utext="${blog.getContent()}">

            </div>

            <!--标签-->
            <div class="m-padded-lr-responsive">
                <div th:each="tag,tagzt:${blog.getTagList()}" class="ui basic teal left pointing label" th:text="${tag.getName()}">方法论</div>

            </div>


            <!--赞赏-->
            <div th:if="${blog.getAppreciation()}" class="ui center aligned basic segment">
                <button id="payButton" class="ui orange basic circular button">赞赏</button>
            </div>
            <div th:if="${blog.getAppreciation()}" class="ui payQR flowing popup transition hidden">
                <div class="ui orange basic label">
                    <div class="ui images" style="font-size: inherit !important;">
                        <div class="image">
                            <img src="/boke/images/zfb.jpg" alt="" class="ui rounded bordered image" style="width: 120px">
                            <div>支付宝</div>
                        </div>

                        <div class="image">
                            <img src="/boke/images/wx.png" alt="" class="ui rounded bordered image" style="width: 120px">
                            <div>微信</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>


        <div th:if="${blog.getShareStatement()}" class="ui attached positive message">
            <!--博客信息-->
            <div class="ui middle aligned grid">
                <div class="eleven wide column">
                    <ui class="list">
                        <li th:text="|${user.getNickname()}|">作者:李仁密(联系作者)</li>
                        <li th:text="|发表时间: ${blog.getCreateDateTime()}|">发表时间: 2017-10-02 09:08</li>
                        <li>版权声明:自由转载-非商用-非衍生保持署名(创意共享3. 0许可证)</li>
                    </ui>
                </div>
                <div class="five wide column">
                    <img src="/boke/images/grwx.jpg" alt="" class="ui right floated rounded bordered image"
                         style="width: 120px">
                </div>
            </div>
        </div>

        <div th:if="${blog.getCommentabled()}" class="ui bottom attached segment">
            <!--留言区域-->
            <div id="comment-container" class="ui teal segment">
                <div th:fragment="commentList">
                    <div class="ui threaded comments" style="max-width:100%">
                        <h3 class="ui dividing header">评论</h3>
                        <div class="comment" th:each="comment,commentzt:${comments}">
                            <a class="avatar">
                                <img src="/boke/images/pltx.jpg">
                            </a>
                            <div class="content">
                                <a class="author" th:text="${comment.getNickname()}">马特(男子名ˌ等于Matthew)</a>
                                <div class="metadata">
                                    <span class="date" th:text="${comment.getCreateDateTime()}">今天下午5:42</span>
                                </div>
                                <div class="text" th:text="${comment.getContent()}">
                                   多有意境啊
                                </div>
<!--                                <div class="actions">-->
<!--                                    <a class="reply" th:data-commentid="${comment.getId()}" th:data-commentnickname="${comment.getNickname()}" onclick="reply(this)">回复</a>-->
<!--                                </div>-->
                                <div th:if="${session.get('nickname') != null}" class="actions">
                                    <a class="reply" th:data-commentid="${comment.getId()}" th:data-commentnickname="${comment.getNickname()}" onclick="removecomment(this)">删除</a>
                                </div>
                            </div>
                            <br>
                        </div>
<!--                        <div class="comment">-->
<!--                            <a class="avatar"> <img src="/boke/images/pltx.jpg"> </a>-->
<!--                            <div class="content">-->
<!--                                <a class="author"><font style="text-align: inherit;">傅</font></a>-->
<!--                                <div class="metadata">-->
<!--                                    <span class="date"><font style="text-align: inherit;">昨天上午12:30</font></span>-->
<!--                                </div>-->
<!--                                <div class="text">-->
<!--                                    <p><font style="text-align: inherit;">这对我的研究非常有用。也谢谢！</font></p>-->
<!--                                </div>-->
<!--                                <div class="actions">-->
<!--                                    <a class="reply"><font style="text-align: inherit;">回答</font></a>-->
<!--                                </div>-->
<!--                            </div>-->
<!--                            <div class="comments">-->
<!--                                <div class="comment">-->
<!--                                    <a class="avatar">-->
<!--                                        <img src="/boke/images/pltx.jpg">-->
<!--                                    </a>-->
<!--                                    <div class="content">-->
<!--                                        <a class="author"><font style="text-align: inherit;">珍妮·赫斯</font></a>-->
<!--                                        <div class="metadata">-->
<!--                                            <span class="date"><font style="text-align: inherit;">刚才</font></span>-->
<!--                                        </div>-->
<!--                                        <div class="text">-->
<!--                                            <font style="text-align: inherit;">埃利奥特你总是这么对:)</font>-->
<!--                                        </div>-->
<!--                                        <div class="actions">-->
<!--                                            <a class="reply"><font style="text-align: inherit;">回答</font></a>-->
<!--                                        </div>-->
<!--                                    </div>-->
<!--                                </div>-->
<!--                            </div>-->
<!--                        </div>-->
<!--                        <div class="comment"><a class="avatar"> <img src="/boke/images/pltx.jpg"> </a>-->
<!--                            <div class="content">-->
<!--                                <a class="author"><font style="text-align: inherit;">乔·亨德森</font></a>-->
<!--                                <div class="metadata"><span class="date"><font-->
<!--                                        style="text-align: inherit;">5天前</font></span>-->
<!--                                </div>-->
<!--                                <div class="text"><font style="text-align: inherit;">伙计，这太棒了。非常感谢</font></div>-->
<!--                                <div class="actions">-->
<!--                                    <a class="reply"><font style="text-align: inherit;">回答</font></a></div>-->
<!--                            </div>-->
<!--                        </div>-->
                    </div>
                </div>
            </div>
            <div id="comment-form" class="ui form">
                <input type="hidden"  name="blogId" th:value="${blog.getId()}">
                <input type="hidden" name="superiorId" value="-1">
                <div cLass="field">
                    <textarea name="content" pLacehoLder="请输入评论信息...." ></textarea>
                </div>
                <div class="fields">
                    <div class="field m-mobile-wide m-margin-bottom-small">
                        <div class="ui left icon input">
                            <i class="mail icon"></i>
                            <input type="text" name="nickname" pLaceholder="姓名">
                        </div>
                    </div>
                    <div class="field m-mobile-wide m-margin-bottom-small">
                        <div class="ui left icon input">
                            <i class="mail icon"></i>
                            <input type="text" name="email" pLaceholder="邮箱">
                        </div>
                    </div>
                    <div class="field m-mobile-wide m-margin-bottom-small">
                        <button id="commentpost-btn" class="ui teal button m-mobile-wide"><i class="edit icon"></i>发布</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<!--尾部-->
<footer class="ui inverted vertical segment m-padded-tb-massive">
    <div class="ui center aligned container">
        <div class="ui inverted divided stackable grid">
            <div class="three wide coLumn">
                <div class="ui inverted link list">
                    <div class="item">
                        <img src="/boke/images/grwx.jpg" class="ui rounded imagel img" alt="" style="width: 100px;">
                    </div>
                </div>
            </div>
            <div class="three wide column">
                <h4 class="ui inverted header m-text-thin m-text-spaced ">最新博客</h4>
                <div class="ui inverted link list">
                    <a href="#" class="item">用户故事</a>
                    <a href="#" class="item">用户故事</a>
                    <a href="#" class="item">用户故事</a>
                </div>
            </div>
            <div class="three wide column">
                <h4 class="ui inverted header m-text-thin m-text-spaced ">最新博客</h4>
                <div class="ui inverted link list">
                    <a href="#" class="item">用户故事</a>
                    <a href="#" class="item">用户故事</a>
                    <a href="#" class="item">用户故事</a>
                </div>
            </div>
            <div class="seven wide column">
                <h4 class="ui inverted header m-text-thin m-text-spaced">最新博客</h4>
                <p class="ui m-text-thin m-text-spaced m-opacity-mini">
                    探索我们“天天向上”的所有方法。了解我们的品牌标志。了解我们的安全流程。了解我们的贡献。者跳到我们的首页。</p>
            </div>
        </div>
    </div>
    <div class="ui inverted section divider">
        <p style="text-align: center; margin-top: 40px;" class="m-text-thin m-text-spaced m-opacity-mini">
            开发于2021.3.20</p>
    </div>

</footer>
<script>
    $('.menu.toggle').click(function () {
        $('.m-item').toggleClass('m-mobile-hide');
    })

    $('#payButton').popup({
        popup: $('.payQR.popup'),
        on: 'click',
        position: "bottom center"
    })

    $('.ui.form').form({
        fields : {
            content: {
                identifier: 'content',
                rules: [{
                    type: 'empty',
                    prompt: '请输入评论信息'
                }]
            },
            nickname: {
                identifier: 'nickname',
                rules: [{
                    type: 'empty',
                    prompt: '请输入你的姓名'
                }]
            },
            email: {
                identifier: 'email',
                rules: [{
                    type: 'empty',
                    prompt: '请输入邮箱地址'
                }]
            }
        }
    });

    $('#commentpost-btn').click(function () {

        var boo = $('.ui.form').form('validate form');

        if(boo)
        {
            console.log('校验成功')
            postData();
            
        }else
        {
            console.log('校验失败')
        }

    })
    
    function postData() {
        $('#comment-container').load("/boke/view/comment",{
            blogId:$("[name='blogId']").val(),
            superiorId:$("[name='superiorId']").val(),
            content:$("[name='content']").val(),
            nickname:$("[name='nickname']").val(),
            email:$("[name='email']").val()
        },function (responseTxt,statusTxt,xhr){
            $(window).scrollTo($('#comment-container'),500);
            clearContent();

        })
    }
    
    function clearContent() {
        $("[name='content']").val('');
        $("[name='superiorId']").val(-1);
    }

    function reply(obj) {
        var commentId = $(obj).data('commentid');
        var commentNickname = $(obj).data('commentnickname');

        $("[name='content']").attr("placeholder","@"+commentNickname).focus();
        $("[name='superiorId']").val(commentId);
        $(window).scrollTo($('#comment-form'),500);

    }

    function removecomment(obj) {
        var commentId = $(obj).data('commentid');


        $('#comment-container').load("/boke/view/rmovecomment",{
            commentId:commentId,
            blogId:$("[name='blogId']").val(),
        })

    }

</script>
</body>
</html>
